******************************
********** Study 2 ***********
******************************
use "study2.dta"


******************
**** Table 4 *****
******************

est clear
reg pride i.exp if minorities==1 , robust
eststo em1
ivreg pride (compliance1 = exp) if minorities==1 & exp<2, robust
eststo em2
ivreg pride (compliance2 = exp) if minorities==1 & exp!=1, robust
eststo em3
ivreg pride (compliance3 = exp) if minorities==1 , robust
eststo em4

esttab em1 em2 em3 em4 using study2.tex, replace b(%12.2f) se title(Experiment)  star(* 0.10 ** 0.05 *** 0.01) 


**********************************
**** SUPPLEMENTARY MATERIAL ******
**********************************
set scheme s1mono
** Figure B1 **
twoway histogram service_negative if minorities==1, percent w(.5) discrete title("Negative Prime") ///
	xlabel(0 "Very dissatisifed" 1 "Dissatisfied" 2 "Satisfied" 3 "Very satisifed") xtitle(" ")
	
twoway histogram service_positive if minorities==1, percent w(.5) discrete title("Positive Prime") ///
	xlabel(0 "Very dissatisifed" 1 "Dissatisfied" 2 "Satisfied" 3 "Very satisifed")  xtitle(" ")

gr combine positiveprime.gph negprime.gph, ycommon


** Figure B2 **
twoway histogram service_shift if minorities==1 & exp==2 , percent w(.5) discrete ///
	title("Negative prime") xtitle("Shifts in service rating")

twoway histogram service_shift if minorities==1 & exp==1 , percent w(.5) discrete ///
	title("Positive prime") xtitle("Shifts in service rating")

gr combine shift_posprime.gph shift_negprime.gph, ycommon

** Figure B3 **
hist pride if minorities==1, percent w(.5) disc  ///
	xlabel(0 "Not proud at all" 1 "Not proud" 2 "Somewhat proud" 3 "Very proud") ///
	xtitle(" ")

** Table B1 **
global BALANCEVARS male age urban edu buddhist income state novisit locality_homogeneous localviolence supportdemocracy chin kachin kayah kayin mon rakhine shan
mata: mata clear

* First test of differences
local i = 1

foreach var in $BALANCEVARS {
    reg `var' i.exp if minorities==1
    outreg,   rtitle("`: var label `var''") stats(b) ///
        noautosumm store(row`i')  starlevels(10 5 1) starloc(1)
    outreg, replay(diff) append(row`i') ctitles("",Difference ) ///
        store(diff) note("")
    local ++i
}
outreg, replay(diff)

* Then Summary statistics
local count: word count $BALANCEVARS
mat sumstat = J(`count',9,.)

local i = 1
foreach var in $BALANCEVARS {
    quietly: summarize `var' if exp==0 &  minorities==1
    mat sumstat[`i',1] = r(N)
    mat sumstat[`i',2] = r(mean)
    mat sumstat[`i',3] = r(sd)
    quietly: summarize `var' if exp==1 &  minorities==1
    mat sumstat[`i',4] = r(N)
    mat sumstat[`i',5] = r(mean)
    mat sumstat[`i',6] = r(sd)
	quietly: summarize `var' if exp==2 & minorities==1
    mat sumstat[`i',7] = r(N)
    mat sumstat[`i',8] = r(mean)
    mat sumstat[`i',9] = r(sd)
    local i = `i' + 1
}
frmttable, statmat(sumstat) store(sumstat) sfmt(g,f,f,g,f,f,g,f,f) 


** Table B2 **
** Karen, Rakhine, and Shan
reg pride service_baseline if ethnicity==4 & exp==0
eststo karen
reg pride service_baseline male age urban buddhist if ethnicity==4 & exp==0
eststo karen1
reg pride service_baseline if ethnicity==7 & exp==0
eststo rakhine
reg pride service_baseline male age urban buddhist if ethnicity==7 & exp==0
eststo rakhine1
reg pride service_baseline if ethnicity==8 & exp==0
eststo shan
reg pride service_baseline male age urban buddhist if ethnicity==8 & exp==0
eststo shan1


** table manually edited
esttab karen karen1 rakhine rakhine1 shan shan1 using groupsinconflict.tex,replace ///
	se title("Service experience and Karen, Rakhine and Shan’s attachment to the state")  ///
	star(* 0.10 ** 0.05 *** 0.01)



